import axios from 'axios'
class HYRequest {
	constructor(baseUrl, timeout = 20000) {
		this.instance = axios.create({
			baseURL: baseUrl,
			timeout: timeout,
		})
	}

	request(config) {
		return new Promise((resolve, resject) => {
			this.instance
				.request(config)
				.then((res) => resolve(res.data))
				.catch((err) => resject(err))
		})
	}

	get(config) {
		return this.request({ ...config, method: 'get' })
	}

	post(config) {
		return this.request({ ...config, method: 'post' })
	}
}

export default new HYRequest('http://123.207.32.32:9001')
